import bisect
from typing import List


class Solution:
    def maximumBeauty(self, items: List[List[int]], queries: List[int]) -> List[int]:
        items.sort(key=lambda item: item[0])
        for i in range(1, len(items)):
            items[i][1] = max(items[i][1], items[i - 1][1])

        for i, target in enumerate(queries):
            j = bisect.bisect_right(items, target, key=lambda item: item[0])
            queries[i] = items[j - 1][1] if j > 0 else 0
        return queries